package com.snooker.snooker.controller;

import com.github.pagehelper.*;
import com.snooker.snooker.dto.ResponseDto;
import com.snooker.snooker.entity.Player;
import com.snooker.snooker.service.PlayerService;
import com.snooker.snooker.vo.PageRequestVo;
import io.swagger.annotations.*;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 球员信息-controller
 * @Param:
 * @return:
 * @Author: fenghouzhi
 * @Date: 2:28 PM 2018/11/6
 */
@Slf4j
@Controller
@Api(tags = "球员信息")
@RequestMapping(value = "/player")
public class PlayerController {

  @Resource
  private PlayerService playerService;

  @ResponseBody
  @ApiOperation(value = "获取全部球员基本信息-含分页")
  @PostMapping("/players")
  ResponseDto getAllPlayer(@RequestBody PageRequestVo pageRequestVo) {
    log.info("page param---{}", pageRequestVo);
    PageHelper.startPage(pageRequestVo.getPageNum(), pageRequestVo.getPageSize());
    List<Player> playerList = playerService.getAllPlayer();
    PageInfo<Player> pageInfo = new PageInfo<>(playerList);
    return ResponseDto.ok("success", pageInfo);
  }

}